/**
 * 融资申请实体类 - 融资业务的核心实体，记录融资申请的完整生命周期
 *
 * 开发人员：陈宏伟
 * 开发时间：2025-10-25 至 2025-10-30
 * 模块职责：定义融资申请的业务属性和状态管理，作为融资系统的数据核心
 *
 * 技术要点：
 * - 多租户关联设计，与企业、用户实体关联
 * - 融资状态枚举管理，支持多种申请状态流转
 * - 金额精度控制，使用BigDecimal确保财务准确性
 * - JSON字段存储复杂业务指标数据
 * - 审计字段自动维护申请时间信息
 *
 * 开发故事：负责融资申请实体的数据模型设计，与融资服务层深度配合，实现融资申请的完整生命周期管理。
 */
package com.pbl.entity;

import com.pbl.common.enums.FinancingRequestStatus;
import lombok.*;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Entity
@Table(name = "financing_requests")
public class FinancingRequest {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "enterprise_id", nullable = false)
    private Enterprise enterprise;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "applicant_user_id")
    private User applicantUser;

    @Column(name = "requested_amount", nullable = false, precision = 12, scale = 2)
    private BigDecimal requestedAmount;

    @Column(length = 255)
    private String purpose;

    @Lob
    @Column(name = "metrics")
    private String metrics; // JSON text

    @Column(name = "score", precision = 5, scale = 2)
    private BigDecimal score;

    @Enumerated(EnumType.STRING)
    @Column(nullable = false, length = 16)
    private FinancingRequestStatus status;

    @Column(name = "created_at", insertable = false, updatable = false)
    private LocalDateTime createdAt;

    @Column(name = "updated_at", insertable = false, updatable = false)
    private LocalDateTime updatedAt;
}
